layui.use(['table', 'layer', 'ax'], function () {
    var table = layui.table;
    var layer = layui.layer;
    var $ = layui.jquery;

    var GroupOrder = {
        tableId: "groupOrderTable"    //表格id
    };

    GroupOrder.initColumn = function () {
        return [[
            {type: 'numbers', align: "center", title: '序号'},
            {field: 'offeringId', align: "center", title: '资费ID'},
            {field: 'offeringName', align: "center", title: '资费名称'},
            {field: 'effectiveDate', align: "center", title: '生效时间'},
            {field: 'expiriedDate', align: "center", title: '失效时间'},
            {field: 'apnName', align: "center", title: 'APN'},
            {align: 'center', toolbar: '#changeableOfferingsBar', title: '可变更资费'}
        ]];
    };

    table.render({
        elem: '#' + GroupOrder.tableId,
        defaultToolbar: [],
        url: Feng.ctxPath + '/ecGroup/groupOrders?groupId=' + $("#ecGroupId").val() + '&accountId=' + $("#ecAccountId").val(),
        height: "full-98",
        cellMinWidth: 100,
        page: true,
        cols: GroupOrder.initColumn()
    });

    // 工具条点击事件
    table.on('tool(' + GroupOrder.tableId + ')', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;
        if (layEvent === 'changeableOfferings') {
            GroupOrder.toChangeableOfferingsBar(data.offeringId);
        }
    });

    /**
     * 弹出 查看群组可变更资费
     */
    GroupOrder.toChangeableOfferingsBar = function (offeringId) {
        layer.open({
            type: 2,
            title: '群组可变更资费',
            area: ['850px', '530px'],
            skin: 'layui-layer-molv',
            content: Feng.ctxPath+'/ecGroup/toChangeableOfferings/' + $("#ecGroupId").val() + '/' + $("#ecAccountId").val() + '/' + offeringId,
            btn: ['关闭']
        });
    };
});